package com.ittest.test;

import com.ittest.entity.*;
import com.ittest.mapper.CarMapper;
import org.junit.jupiter.api.Test;

/**
 * @className: OneDemo
 * @description: TODO
 * @author: cheetah
 * @date: 2021/10/13 16:36
 * @Version: 1.0
 */
public class OneDemo {

    @Test
    public void shouldMapCarToDto() {

        Car car = new Car( "Morris", 5, CarType.SEDAN );
        CarDto carDto = CarMapper.INSTANCE.carToCarDto( car );

        System.out.println(carDto);
    }


    @Test
    public void shouldMapCarVoToDto() {

        CarVo carVo = new CarVo( "Morris", 5, false );
        CarDto carDto = CarMapper.INSTANCE.carVoToCarDto( carVo );

        System.out.println(carDto);
    }

    @Test
    public void mapCarVoToDtoWithExpression() {

        CarVo carVo = new CarVo( "Morris", 5, false );
        CarDto carDto = CarMapper.INSTANCE.carVoToDtoWithExpression( carVo );

        System.out.println(carDto);
    }


    @Test
    public void updateBwmCar() {
        Car car = new Car( "Morris", 5, CarType.SEDAN );
        BMWCar bwmCar = new BMWCar("BWM", 5, CarType.SPORTS, "RED", "50w");
        System.out.println("更新前 car:"+car.toString());
        System.out.println("更新前 BWMCar:"+bwmCar.toString());

        CarMapper.INSTANCE.updateBwmCar(car, bwmCar);

        System.out.println("更新后 car:"+car.toString());
        System.out.println("更新后 BWMCar:"+bwmCar.toString());
    }


    @Test
    public void mallCarToBenzMall() {
        Car car = new Car( "Morris", 5, CarType.SEDAN );
        Mall4S mall4S = new Mall4S("北京市", "135XXXX4503");
        Benz4SMall benz4SMall = CarMapper.INSTANCE.mallCarToBenzMall(null, mall4S);
        System.out.println(benz4SMall.toString());
    }
}
